#include <PrefixTree.hpp>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


int main(int argc, char **argv){
	if (argc < 2){
		fprintf(stderr, "usage: wordsfile\n" );
		PrefixTree pref;

		pref.AddWord("face",1);
		pref.AddWord("palm",1);
		pref.AddWord("park",1);
		pref.AddWord("facepalm",1);
		pref.AddWord("facepalm",1);
		pref.AddWord("facebook",1);
		string str = "";
		 pref.RecursiveTour(0, str);
		return EX_USAGE;
	}

	fprintf(stderr, "it doesn't work with utf-8");
	PrefixTree *pref = new PrefixTree();
	UINT_32 currentIDF;
	CHAR_8 currentWord[MAX_WORD_LENGTH];
	FILE *f = fopen(argv[1], "r");
	fprintf(stderr, "here \n");
	UINT_32 Ii = 0;
	fprintf(stderr, "sizeof=%u\n", sizeof(PrefixTreeNode));
	while (!feof(f) && fscanf(f, "%u%s", &currentIDF, currentWord) && Ii < 10000){
		pref->AddWord(currentWord, currentIDF);
		fprintf(stdout, "%d - size of PrefixTree : #%u : %s with IDF=%u was added to prefix tree\n", pref->size, Ii, currentWord,     currentIDF);
	++Ii;
	}
}
